//Copyright (c) 2010, Goodwine & Tibia ML
//Licensed under new BSD License.

function saveLinks(tml,exh)
{
	localStorage.tml = tml.checked;
	localStorage.exh = exh.checked;
	_trackOption('TML Link', tml.checked ? 'set' : 'unset');
	_trackOption('EXH Link', exh.checked ? 'set' : 'unset');
	enableLinkControls(false);
	alert('Link options have been saved');
}

function recallLinks()
{
		tml.checked = JSON.parse(localStorage.tml);
		exh.checked = JSON.parse(localStorage.exh);
		var opLinkPages = JSON.parse(localStorage.opLinkPages);
		forum_links.checked = opLinkPages.forum;
		guild_links.checked = opLinkPages.guild;
		//world_links.checked = opLinkPages.world;
		enableLinkControls(false);
}

function setLinkPages(forum, guild, world) {
	var opLinkPages = {
		'forum' : forum.checked,
		'guild' : guild.checked,
		'world' : false
	};
	_trackOption('Forum Link', forum.checked ? 'set' : 'unset');
	_trackOption('Guild Link', guild.checked ? 'set' : 'unset');
	//_trackOption('World Link', world.checked ? 'set' : 'unset');
	localStorage.opLinkPages = JSON.stringify(opLinkPages);
}

$(function() {
	$('#links input').change(enableLinkControls).keydown(enableLinkControls);
	recallLinks();
});

function enableLinkControls(enabled) {
	enabled = enabled || false;
	$('#links .submit input').attr('disabled', !enabled);
}